package com.smart.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.smart.common.dao.AbstractDao;
import com.smart.domain.User;
import com.smart.tools.ObjectHelper;

/**
 * 
 * 版权所有：xxxxxxx
 * @Description: 用户
 * @Title: UserDao.java 
 * @ClassName: UserDao 
 * @author tangyan 
 * @date 2019年2月13日 下午6:28:46 
 * @version V1.0
 */
@Repository
@Transactional
public class UserDao extends AbstractDao<User>{

	/**
	 * 
	 * @Title: queryUser 
	 * @Description: 查询用户
	 * @author tangyan 
	 * @param conditions
	 * @return
	 */
	public List<User> queryUser(Map<String, Object> conditions){
		StringBuffer hql = new 	StringBuffer(" from User u  where u.isDeleted = 0 ");
		if(ObjectHelper.isNotEmpty(conditions.get("userName"))){
			hql.append(" and u.userName = :userName ");
		}
		
		if(ObjectHelper.isNotEmpty(conditions.get("identityCard"))){
			hql.append(" and u.identityCard = :identityCard ");
		}
		
		if(ObjectHelper.isNotEmpty(conditions.get("phoneNumber"))){
			hql.append(" and u.phoneNumber = :phoneNumber ");
		}
		
		return this.findByHql(hql.toString(), conditions);
	}

}
